Skip to content

tools: conformance map checker (#7) - #66

Merged
michaelstonis merged 2 commits into
mainfrom
7-conformance-map-checker
Oct 9, 2026
Merged

michaelstonis merged 2 commits into
mainfrom
7-conformance-map-checker

Conversation

@michaelstonis

Copy link
Copy Markdown
Owner

Closes #7

Summary

Adds tools/ConformanceCheck (console, net10.0, root namespace Broadside.Tools.ConformanceCheck, no package references) and tests/ConformanceCheck.Tests, and documents the row formats and rules in docs/conformance/README.md.

The tool. ConformanceMap.cs holds the parser, the code index and the rules as public types; Program.cs is argument parsing and console output. CLI: --root <dir> (default: walk up from the current directory to the folder containing Broadside.slnx), --summary (Markdown table of row counts per status per file, plus a total), --strict (also fail partial rows with an empty Tests or Notes cell). Exit 0 when valid, 1 when any rule fails (one line per violation, docs/conformance/<file>.md:<line>: <message>), 2 for a usage error or a root without docs/conformance.

Rules enforced over every docs/conformance/*.md except README.md:

  1. Every table row has exactly six cells; the header is Clause | Title | Status | Implementing types | Tests | Notes.
  2. Clause is non-empty and unique within the file.
  3. Status is one of not started, partial, done, n/a.
  4. A done row names at least one test.
  5. An n/a row has a non-empty Notes cell.
  6. Every Tests identifier resolves to a test class or a [Fact]/[Theory] method under tests/**/*.cs.
  7. Every Implementing types name is declared as a class, struct, interface, enum or record under src/**/*.cs.
  8. --strict only: a partial row names at least one test and has a non-empty Notes cell.

The code lookups are a line-level regex scan (namespace, type declarations, attributed method declarations), not Roslyn; bin, obj and Fixtures directories are skipped.

Cell formats (documented in docs/conformance/README.md):

  • Tests: comma-separated backticked identifiers, each a fully qualified test method `Namespace.Class.Method` or a test class `Namespace.Class`. The class is the one that directly declares the method, in the namespace its file declares; the method must carry [Fact] or [Theory].
  • Implementing types: comma-separated backticked simple type names (`CosDictionary`, `CosLexer`), no namespace, no type arguments.

The tests. Nine fixture repositories under tests/ConformanceCheck.Tests/Fixtures/<case>/ (each a docs/conformance/x.md, tests/Foo.Tests/FooTests.cs, src/Foo/Foo.cs; the .cs files are Compile Removed and copied to output), one test per case asserting the exact violation line: valid map, done without tests, done naming a non-test method, bad status, wrong cell count, n/a without notes, duplicate clause, missing implementing type, and partial without tests/notes (passes by default, two violations under --strict). Plus a summary-format test, a missing-directory test, and Repository_conformance_map_is_valid, which runs the checker against the checkout on every dotnet test Broadside.Core.slnf.

Wiring. Tool under /tools/ and test project under /tests/ in Broadside.slnx; test project added to Broadside.Core.slnf. The CI job from #4 invokes dotnet run --project tools/ConformanceCheck -- --root . --summary, verified below from the repo root.

Not done. No existing conformance file needed changes: all 207 rows are not started and the checker reports zero violations. No PublicAPI.Unshipped.txt changes (nothing under src/ changed).

Deliverables

  • Code with XML docs (no spec clauses apply: tooling only)
  • Tests (unit, via fixtures, plus the real-repository check)
  • Conformance map rows updated: none needed; docs/conformance/README.md documents the formats and rules
  • PublicAPI.Unshipped.txt unchanged (no src/ changes)
  • Benchmark: not a hot path
  • DCO sign-off: commits carry the Co-Authored-By trailer per the repository's agent attribution rule

Public API changes

none

Verification

dotnet build Broadside.slnx -warnaserror -p:BroadsideBuildPlatformBackends=false

Build succeeded.
    0 Warning(s)
    0 Error(s)

DiffEngine_Disabled=true dotnet test Broadside.Core.slnf

ConformanceCheck.Tests.dll (net10.0|arm64) passed (620ms)
  total: 49
  failed: 0
  succeeded: 49
  skipped: 0

dotnet run --project tools/ConformanceCheck -- --root . --summary (exit 0)

| Specification | not started | partial | done | n/a | Rows |
|---|---:|---:|---:|---:|---:|
| iso-14289-1.md | 31 | 0 | 0 | 0 | 31 |
| iso-14289-2.md | 18 | 0 | 0 | 0 | 18 |
| iso-32000-2.md | 96 | 0 | 0 | 0 | 96 |
| iso-ts-32001.md | 2 | 0 | 0 | 0 | 2 |
| iso-ts-32002.md | 5 | 0 | 0 | 0 | 5 |
| iso-ts-32003.md | 3 | 0 | 0 | 0 | 3 |
| iso-ts-32004.md | 9 | 0 | 0 | 0 | 9 |
| iso-ts-32005.md | 10 | 0 | 0 | 0 | 10 |
| pdf-declarations.md | 5 | 0 | 0 | 0 | 5 |
| pdf20-an001.md | 4 | 0 | 0 | 0 | 4 |
| pdf20-an002.md | 5 | 0 | 0 | 0 | 5 |
| pdf20-an003.md | 3 | 0 | 0 | 0 | 3 |
| wtpdf-1.0.md | 16 | 0 | 0 | 0 | 16 |
| **Total** | 207 | 0 | 0 | 0 | 207 |

Conformance map OK: 13 files, 207 rows, 0 violations.

dotnet run --project tools/ConformanceCheck -- --root tests/ConformanceCheck.Tests/Fixtures/done-with-missing-test --summary (exit 1)

docs/conformance/x.md:7: test 'Foo.Tests.FooTests.Helper' was not found in tests/: no class 'Foo.Tests.FooTests.Helper' and no [Fact]/[Theory] method 'Helper' on class 'Foo.Tests.FooTests'

| Specification | not started | partial | done | n/a | Rows |
|---|---:|---:|---:|---:|---:|
| x.md | 1 | 0 | 1 | 0 | 2 |
| **Total** | 1 | 0 | 1 | 0 | 2 |

Conformance map FAILED: 1 violation(s) in 1 files, 2 rows.

Also checked by hand that the index resolves real code: a temporary row citing `Broadside.Tests.CorpusSmokeTests.Well_formed_file_has_pdf_header_and_eof_marker`, `Broadside.Tests.CorpusSmokeTests` and `AssemblyMarker` passed, and a sibling row with bare text in the Tests cell and a type Nope produced exactly two violations. The row was reverted before committing.

🤖 Generated with Claude Code

Add tools/ConformanceCheck, a console tool with no package references
that parses every docs/conformance/*.md except README.md and enforces
the row rules: six cells per row, a known status, tests on done rows,
notes on n/a rows, unique clauses, and every cited test and implementing
type present in tests/ and src/ (a line-level regex scan, no Roslyn).
Violations print as docs/conformance/<file>.md:<line>: <message>;
--summary prints a Markdown table of counts per status; --strict also
requires tests and notes on partial rows. Exit 0 valid, 1 violations,
2 usage error.

tests/ConformanceCheck.Tests drives the checker against one fixture
repository per rule, asserting the exact violation, and against the
real checkout, so dotnet test Broadside.Core.slnf fails when the map is
wrong. docs/conformance/README.md documents the Tests and Implementing
types cell formats, the rules, and how to run the checker locally and
in CI.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The checker currently accepts headerless maps, malformed identifier lists, and invalid test references.

7 open findings
What changed in this PR

Adds a .NET conformance-map checker that validates documentation rows, code references, and status rules.

Changes:

  • Implements the checker CLI, parser, code index, validation, and summaries.
  • Adds fixture-based tests and repository-wide validation.
  • Documents formats and wires projects into solution builds.
File Description
tools/​ConformanceCheck/​README.md Documents tool usage and behavior.
tools/​ConformanceCheck/​Program.cs Implements CLI handling and output.
tools/​ConformanceCheck/​ConformanceMap.cs Implements parsing, indexing, validation, and reporting.
tools/​ConformanceCheck/​ConformanceCheck.csproj Defines the console project.
tests/​ConformanceCheck.Tests/​ConformanceCheckerTests.cs Tests rules, summaries, and repository validation.
tests/​ConformanceCheck.Tests/​ConformanceCheck.Tests.csproj Configures tests and fixture copying.
tests/​ConformanceCheck.Tests/​Fixtures/​valid/​docs/​conformance/​x.md Provides a valid map fixture.
tests/​ConformanceCheck.Tests/​Fixtures/​valid/​src/​Foo/​Foo.cs Provides valid source types.
tests/​ConformanceCheck.Tests/​Fixtures/​valid/​tests/​Foo.Tests/​FooTests.cs Provides valid test identifiers.
tests/​ConformanceCheck.Tests/​Fixtures/​wrong-cell-count/​docs/​conformance/​x.md Exercises malformed row detection.
tests/​ConformanceCheck.Tests/​Fixtures/​wrong-cell-count/​src/​Foo/​Foo.cs Supplies fixture source types.
tests/​ConformanceCheck.Tests/​Fixtures/​wrong-cell-count/​tests/​Foo.Tests/​FooTests.cs Supplies fixture tests.
tests/​ConformanceCheck.Tests/​Fixtures/​partial-without-tests/​docs/​conformance/​x.md Exercises strict partial-row rules.
tests/​ConformanceCheck.Tests/​Fixtures/​partial-without-tests/​src/​Foo/​Foo.cs Supplies fixture source types.
tests/​ConformanceCheck.Tests/​Fixtures/​partial-without-tests/​tests/​Foo.Tests/​FooTests.cs Supplies fixture tests.
tests/​ConformanceCheck.Tests/​Fixtures/​na-without-notes/​docs/​conformance/​x.md Exercises required n/a notes.
tests/​ConformanceCheck.Tests/​Fixtures/​na-without-notes/​src/​Foo/​Foo.cs Supplies fixture source types.
tests/​ConformanceCheck.Tests/​Fixtures/​na-without-notes/​tests/​Foo.Tests/​FooTests.cs Supplies fixture tests.
tests/​ConformanceCheck.Tests/​Fixtures/​missing-implementing-type/​docs/​conformance/​x.md Exercises missing type detection.
tests/​ConformanceCheck.Tests/​Fixtures/​missing-implementing-type/​src/​Foo/​Foo.cs Supplies known source types.
tests/​ConformanceCheck.Tests/​Fixtures/​missing-implementing-type/​tests/​Foo.Tests/​FooTests.cs Supplies fixture tests.
tests/​ConformanceCheck.Tests/​Fixtures/​duplicate-clause/​docs/​conformance/​x.md Exercises duplicate clause detection.
tests/​ConformanceCheck.Tests/​Fixtures/​duplicate-clause/​src/​Foo/​Foo.cs Supplies fixture source types.
tests/​ConformanceCheck.Tests/​Fixtures/​duplicate-clause/​tests/​Foo.Tests/​FooTests.cs Supplies fixture tests.
tests/​ConformanceCheck.Tests/​Fixtures/​done-without-tests/​docs/​conformance/​x.md Exercises required done-row tests.
tests/​ConformanceCheck.Tests/​Fixtures/​done-without-tests/​src/​Foo/​Foo.cs Supplies fixture source types.
tests/​ConformanceCheck.Tests/​Fixtures/​done-without-tests/​tests/​Foo.Tests/​FooTests.cs Supplies fixture tests.
tests/​ConformanceCheck.Tests/​Fixtures/​done-with-missing-test/​docs/​conformance/​x.md Exercises unresolved test detection.
tests/​ConformanceCheck.Tests/​Fixtures/​done-with-missing-test/​src/​Foo/​Foo.cs Supplies fixture source types.
tests/​ConformanceCheck.Tests/​Fixtures/​done-with-missing-test/​tests/​Foo.Tests/​FooTests.cs Provides a non-test method reference.
tests/​ConformanceCheck.Tests/​Fixtures/​bad-status/​docs/​conformance/​x.md Exercises invalid status detection.
tests/​ConformanceCheck.Tests/​Fixtures/​bad-status/​src/​Foo/​Foo.cs Supplies fixture source types.
tests/​ConformanceCheck.Tests/​Fixtures/​bad-status/​tests/​Foo.Tests/​FooTests.cs Supplies fixture tests.
docs/​conformance/​README.md Defines row formats, rules, and invocation.
Broadside.slnx Adds checker and test projects.
Broadside.Core.slnf Includes checker tests in core testing.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +89 to +90
bool isHeader = i + 1 < lines.Count && IsSeparator(SplitCells(lines[i + 1].Trim()));
if (isHeader)
}

/// <summary>Whether a type named <paramref name="fullName"/> (<c>Namespace.Class</c>) is declared under <c>tests/</c>.</summary>
public bool HasTestClass(string fullName) => _testClasses.ContainsKey(fullName);
Comment on lines +316 to +317
[GeneratedRegex(@"\[\s*(?:[A-Za-z_]\w*\.)*\w*(?:Fact|Theory)(?:Attribute)?\s*[\](,]")]
private static partial Regex TestAttribute();
Comment on lines +547 to +559
foreach (Match match in matches)
{
string identifier = match.Groups[1].Value.Trim();
if (identifier.Length == 0)
{
return false;
}

identifiers.Add(identifier);
}

string remainder = Backticked().Replace(cell, string.Empty);
return remainder.All(static c => c == ',' || char.IsWhiteSpace(c));
## Running the checker

```sh
dotnet run --project tools/ConformanceCheck -- --summary # from anywhere inside the checkout
/// One fixture repository per rule under <c>Fixtures/</c> (copied next to the test assembly), each with a <c>docs/conformance/x.md</c>,
/// a <c>tests/Foo.Tests/FooTests.cs</c> and a <c>src/Foo/Foo.cs</c>, plus a run against the real checkout so <c>dotnet test</c> fails when the map is wrong.
/// </summary>
public class ConformanceCheckerTests
Validates the conformance map in `docs/conformance/`. The rules, the cell formats and how to run it are in [docs/conformance/README.md](../../docs/conformance/README.md); this file is only the tool's own notes.

```sh
dotnet run --project tools/ConformanceCheck -- --summary # from anywhere inside the checkout
@michaelstonis
michaelstonis merged commit f467d08 into main Oct 9, 2026
7 checks passed
@michaelstonis
michaelstonis deleted the 7-conformance-map-checker branch October 9, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Scaffold] Conformance map checker

2 participants